import threading
import time
import schedule

schedule.every()

choose=-1#全局变量，记录当前的输入，-1表示没有输入，数字和menu对应
runned=-1#全局变量，记录当前正在运行的状态，数字和menu对应

def sd():
    print(time.time())
    global choose
    choose="1"

def ds():
    schedule.every().day.at("15:57").do(sd)  
    schedule.every().day.at("15:58").do(sd) 
    #如果方法需要传参的话do(func,参数1)
    #开循环
    while True:
        schedule.run_pending()

def menu():#显示菜单
    '''显示菜单'''
    while True:
        if runned==-1:
            print()
            print()
            print("=====剑侠风云挂机小工具v1.0=====")
            print("=========1.矿点扫荡=============")
            print("=========2.免费元宝秘籍和角色===")
            print("=========3.每日奖励=============")
            print("=========4.一键完成=============")
            print("=========0.退出=================")
            print()
            global choose
            choose=input("请输入对应功能的数字：")
            if choose=="0":
                return
        time.sleep(1)

def main():
    m=threading.Thread(target=menu)#显示菜单
    m.start()
    d=threading.Thread(target=ds)#启动定时任务
    d.start()
    global choose
    global runned
    while choose!="0":
        time.sleep(0.1)
        if choose=="1":
            choose=-1
            runned=1
            for i in range(10):
                time.sleep(0.1)
                print("====1. "+str(i)+"====")
            runned=-1
        if choose=="2":
            choose=-1
            runned=2
            for i in range(10):
                time.sleep(0.1)
                print("====2. "+str(i)+"====")
            runned=-1
        if choose=="3":
            choose=-1
            runned=3
            for i in range(10):
                time.sleep(0.1)
                print("====3. "+str(i)+"====")
            runned=-1

if __name__=="__main__":
    main()